home *** CD-ROM | disk | FTP | other *** search
- #include <Application.h>
- #include <View.h>
- #include <Window.h>
- #include <Bitmap.h>
- #include <fcntl.h>
- #include <debugger.h>
-
- #include "RDriver.h"
- #include "mainMADSimple.h"
-
- //---------------------------------------------
-
- class MADWindow : public BWindow {
-
- public:
- MADWindow(BRect frame);
- void MessageReceived(BMessage *msg);
-
- virtual bool QuitRequested();
- };
-
- //---------------------------------------------
-
- class MADView : public BView {
-
- public:
- MADView(BRect frame, char *name);
- virtual void AttachedToWindow();
- virtual void Draw(BRect updateRect);
- };
-
- //---------------------------------------------
-
- main()
- {
- MyApp* curApp = new MyApp('SNPL');
-
- curApp->Run();
-
- delete curApp;
-
- return 0;
- }
- //---------------------------------------------
-
-
- MyApp::MyApp( ulong signature) : BApplication(signature)
- {
- MADDriverSettings init;
-
- init.numChn = 4;
- init.outPutBits = 16;
- init.outPutRate = 44100L << 16L;
- init.outPutMode = DeluxeStereoOutPut;
- init.driverMode = BeOSSoundDriver;
- init.antiAliasing = false;
- init.repeatMusic = true;
- init.Interpolation = true;
- init.MicroDelay = true;
- init.MicroDelaySize = 50;
- init.surround = false;
- init.sysMemory = false;
- init.Reverb = false;
- init.ReverbSize = 45;
- init.ReverbStrength = 60;
- init.TickRemover = true;
-
- myMADDriverClass = new MADDriverClass( &init);
-
-
-
- MADWindow *aWindow;
- MADView *aView;
- BRect aRect;
-
- // set up a rectangle and instantiate a new window
- aRect.Set(40, 40, 400, 80);
- aWindow = new MADWindow(aRect);
-
- // set up a rectangle and instantiate a new view
- // view rect should be same size as window rect but with left top at (0, 0)
- aRect.OffsetTo(B_ORIGIN);
- aView = new MADView(aRect, "MADText");
-
- // add view to window
- aWindow->AddChild(aView);
-
- // make window visible
- aWindow->Show();
- }
-
- MyApp::~MyApp()
- {
- delete myMADDriverClass;
- }
-
- /* Files dropped on the application will end up here */
-
- void MyApp::RefsReceived (BMessage * message)
- {
- for (int cnt = 0; ; cnt++)
- {
- if (message->HasRef("refs", cnt))
- {
- record_ref refs = message->FindRef("refs", cnt);
-
- if (does_ref_conform(refs, "File"))
- {
- BFile file(refs);
- myMADDriverClass->LoadMusic(file);
- }
- }
- else break;
- }
- }
-
- //-----------------------------------------------------
-
- MADWindow::MADWindow(BRect frame)
- : BWindow(frame, "MADDriver", B_TITLED_WINDOW, B_NOT_RESIZABLE)
- {
- }
-
- void MADWindow::MessageReceived(BMessage *msg)
- {
- if (msg->what == B_SIMPLE_DATA)
- {
- BMessage* msg2 = new BMessage( msg);
- msg2->what = B_REFS_RECEIVED;
- be_app->PostMessage(msg2);
- }
- else BWindow::MessageReceived( msg);
- }
-
- bool MADWindow::QuitRequested()
- {
- be_app->PostMessage(B_QUIT_REQUESTED);
- return(TRUE);
- }
-
-
- //------------------------------------------------------
-
- MADView::MADView(BRect rect, char *name)
- : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
- {
- }
-
-
- void MADView::AttachedToWindow()
- {
- SetFontName("Times New Roman");
- SetFontSize(18);
- }
-
-
- void MADView::Draw(BRect)
- {
- MovePenTo(BPoint(10, 30));
- DrawString("Drag a MADH music on this window!");
- }
-